package io;
import java.net.URI;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

public class FileSystemCat {
	 
	public static void main(String[] args) throws Exception {
		String uri="hdfs://node1:9000";
		Configuration conf =new Configuration();
		FileSystem fs=FileSystem.get(URI.create(uri),conf);
		FSDataInputStream in = null;	
		try {
			//in=fs.open(new Path(uri));
			in=fs.open(new Path("/user/hadoop/test1.txt"));
			IOUtils.copyBytes(in, System.out, 4096,false);
			in.seek(0);
			IOUtils.copyBytes(in, System.out, 4096,false);

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			IOUtils.closeStream(in);
		}
	}
}
